package com.ruoyi.common.security.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import com.ruoyi.common.core.utils.StringUtils;

/**
 * 导入 SecurityImportBeanDefinitionRegistrar 自动加载类
 *
 * @author ruoyi
 */
public class SecurityImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar
{
    private static final Logger log = LoggerFactory.getLogger(SecurityImportBeanDefinitionRegistrar.class);
    @Override
    public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry)
    {
        Class<ResourceServerConfig> aClass = ResourceServerConfig.class;
        String beanName = StringUtils.uncapitalize(aClass.getSimpleName());

        log.info("注册默认的bean = " +beanName);

        BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(ResourceServerConfig.class);

        log.info("注册默认的bean2 = " +beanDefinitionBuilder.getBeanDefinition());

        registry.registerBeanDefinition(beanName, beanDefinitionBuilder.getBeanDefinition());
    }
}
